home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / falcon / nt_dsp2.lzh / NT_DSP2.MSA / BENCH / 4-56.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-07-18  |  3.7 KB  |  95 lines

  1.     page 132,66,0,6
  2.         opt  rc
  3. ;*******************************************
  4. ;Motorola Austin DSP Operation  June 30,1988
  5. ;*******************************************
  6. ;DSP56000/1
  7. ;8 pole 4 multiply cascaded canonic IIR filter
  8. ;File name: 4-56.asm
  9. ;**************************************************************************
  10. ;    Maximum sample rate: 410.0 Khz at 20.5 MHZ/ 540.0 KHz at 27.0 MHz
  11. ;    Memory Size: Prog: 6+10 words ; Data :4(2+4) words
  12. ;    Number of clock cycles:    50 (25 instruction cycles)
  13. ;    Clock Frequency:    20.5MHz/27.0MHz
  14. ;    Cycle time:        97.5ns /  74.1ns
  15. ;**************************************************************************
  16. ;    This IIR filter reads the input sample
  17. ;    from the memory location Y:input
  18. ;    and writes the filtered output sample
  19. ;    to the memory location Y:output
  20. ;
  21. ;    The samples are stored in the X memory
  22. ;    The coefficients are stored in the Y memory
  23. ;
  24. ;
  25. ;    The equations of the filer are:
  26. ;       w(n) =    x(n) - ai1*w(n-1) - ai2*w(n-2)
  27. ;       y(n) =    w(n) + bi1*w(n-1) + bi2*w(n-2)
  28. ;
  29. ;                     w(n)
  30. ;   x (n)------(-)---------->-|->---------(+)-------> y(n)
  31. ;               A             |            A
  32. ;               |            1/z           |
  33. ;               |             | w(n-1)     |
  34. ;               |             v            |
  35. ;               |-<--ai1----<-|->---bi1-->-|
  36. ;               |             |            |
  37. ;               |            1/z           |
  38. ;               |             | w(n-2)     |
  39. ;               |             v            |
  40. ;               |-<--ai2----<--->---bi2-->-|
  41. ;
  42. ;    All coefficents are divided by 2:
  43. ;    w(n)/2= x(n)/2 - ai1/2*w(n-1) -ai2/2*w(n-2)
  44. ;    y(n)/2= w(n)/2 + bi1/2*w(n-1) +bi2/2*w(n-2)
  45. ;
  46. ;       X Memory Organization            Y Memory Organization
  47. ;         |         |                          |   b1N/2 | Coef. + 4*nsec-1
  48. ;         |         |                          |   b2N/2 |
  49. ;         |         |                          |   a1N/2 |
  50. ;         |         |                          |   a2N/2 |
  51. ;         | wN(n-1) | Data + 2*nsec-1          |    .    |
  52. ;         | wN(n-2) |                          |    .    |
  53. ;         |   .     |                          |   b11/2 |
  54. ;         |   .     |                          |   b21/2 |
  55. ;         | w1(n-1) |                          |   a11/2 |
  56. ;    R0 ->| w1(n-2) | Data                R4 ->|   a21/2 | Coef.
  57. ;         |         |                          |         |
  58. ;
  59. ;*************************************************************************
  60. ;
  61. ;    initialization
  62. ;**********************
  63. nsec    equ    4
  64. start    equ    $40
  65. data    equ    0
  66. coef    equ    0
  67. input    equ    $ffe0
  68. output  equ    $ffe1
  69. igain    equ    0.5
  70.  
  71.     ori     #$08,mr              ;set scaling mode
  72.     move    #data,r0              ;point to filter states
  73.     move    #coef,r4              ;point to filter coefficients
  74.     move    #2*nsec-1,m0                                  
  75.     move    #4*nsec-1,m4                                      
  76.     move    #igain,y1                 ;y1=initial gain
  77.  
  78.     opt     cc
  79. ;      filter loop: 4*nsec + 9
  80. ;*************************************************                                   
  81.     movep   y:input,y0                         ;get sample
  82.     mpy    y0,y1,a     x:(r0)+,x0  y:(r4)+,y0  ;x0=1st section w(n-2),y0=a12/2
  83. ;
  84.     do       #nsec,end_cell                 ;do each section
  85.     mac    -x0,y0,a     x:(r0)-,x1  y:(r4)+,y0  ;x1=w(n-1) ,y0=ai1/2
  86.     macr   -x1,y0,a     x1,x:(r0)+  y:(r4)+,y0  ;push w(n-1) to w(n-2),y0=bi2/2
  87.     mac    x0,y0,a     a,x:(r0)+   y:(r4)+,y0  ;push w(n) to w(n-1),y0=bi1/2
  88.     mac    x1,y0,a     x:(r0)+,x0  y:(r4)+,y0  ;next iter:x0=w(n-2),y0=ai2/2
  89. end_cell
  90.     rnd    a                     ;round result
  91.     movep        a,y:output         ;output sample
  92. ;*************************************************                                   
  93.     end
  94.  
  95.